# -*- coding:utf-8 -*-
"""
@Author : 审心
@Time : 2023/5/6 20:48
"""
from typing import Tuple

from autoTask.taobao.redis_key_mange import RedisKey
from autoTask.taobao.sycm.gjc.competitorGoodKey import GoodsFeature
from common.redis import redis_client
from common.utils import ObjUtil, DateUtil

key_prefix = RedisKey.sycm.jpfx.key


class CompetingContrast:
    """
    竞品对比
    """

    @staticmethod
    def build_key(gf: GoodsFeature):
        return key_prefix + f"竞品对比:{gf.date_cycle}:{gf.goods_id}:{gf.competing1}-{gf.competing2}"

    @staticmethod
    def put(gf: GoodsFeature, content_tuple: Tuple[str, str, str], ex=DateUtil.seconds_until_end_of_day(1)):
        if ObjUtil.has_none(content_tuple):
            return
        redis_client.put(CompetingContrast.build_key(gf), content_tuple, ex=ex)

    @staticmethod
    def get(gf: GoodsFeature) -> Tuple[str, str, str]:
        return redis_client.get(CompetingContrast.build_key(gf), tuple)
